import { Message } from 'element-ui'

export const showResponse = (res, errorMessage, successMessage) => {
  if (res) {
    if (res.code === 0) {
      Message({
        message: successMessage || res.data,
        type: 'success',
        center: true
      })
      return true
    } else {
      Message({
        message: res.message || errorMessage,
        type: 'error',
        center: true
      })
    }
  } else {
    Message({
      message: errorMessage,
      type: 'error',
      center: true
    })
  }
  return false
}
export const showResponseData = (res, errorMessage, successMessage) => {
  showResponse(res.data, errorMessage, successMessage)
}
